<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends MY_Controller{
	var $hours = array();
	
	function __construct()
	{
		parent::__construct();
		$this->hours= hour::find('all',array('order'=>'hour asc'));
	}

	function index()
	{
		if($_POST)
		{
				
				$shop_id = $_POST['shop_id'];
				$shop = shop::find_by_id($shop_id);
				$url = $shop->url;
				if ($url) 
				{
					redirect($url);
				}
		}else{

			$data['files'] = get_dir_file_info('lunch_pdf', $top_level_only = TRUE);
			$data['cartes'] = get_dir_file_info('carte_pdf', $top_level_only = TRUE);
			$data['title']= $this->title('home');
			$data['shop'] = shop::find('all',array('conditions'=>array('status','1')));
			$data['hours'] = $this->hours;
			$data['communes'] = community::get_communities();
			$this->load->view('header_home',$data);
			$this->load->view('welcome_message');
			$this->load->view('footer');
		}
	}




}